package com.viettel.rmsmobile;

import java.util.ArrayList;
import java.util.List;

import com.viettel.rmsmobile.R;

import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.viettel.BO.CandidateBean;
import com.viettel.BO.CandidateBean;

public class CandidateCareerAdapter extends
		ArrayAdapter<CandidateBean> {
	private List<CandidateBean> data = new ArrayList();
	private Handler hl;
	private Context context;
	int layoutResourceId;

	public CandidateCareerAdapter(Context context, int layoutResourceId,
			List<CandidateBean> data) {
		super(context, layoutResourceId, data);
		this.layoutResourceId = layoutResourceId;
		this.context = context;
		this.data = data;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView; // Lay view cua ListItem
		if (row == null) {
			LayoutInflater inflater = ((Activity) context).getLayoutInflater();
			row = inflater.inflate(layoutResourceId, parent, false);
		}
		final CandidateBean item = data.get(position);
		if (item != null) {
			TextView positionName = (TextView) row
					.findViewById(R.id.positionName);
			TextView organizationName = (TextView) row
					.findViewById(R.id.organizationName);
			TextView status = (TextView) row
					.findViewById(R.id.status);
			LinearLayout linearItemLayout = (LinearLayout) row
					.findViewById(R.id.linear_item_job);

			if (item.getPositionName() != null) {
				positionName.setText(item.getPositionName() + "");
			}
			if (item.getOrganizationName() != null) {
				organizationName.setText(item.getOrganizationName() + "");
			}
			if (item.getStatus() != null) {
				status.setText(item.getStatus() + "");
			}
			Object obj;
			if (position % 2 != 0) {
				obj = 0x7f07000f;
				linearItemLayout.setBackgroundResource(android.R.color.background_light);
			} else{
				obj = 0x7f07000e;
				linearItemLayout.setBackgroundResource(android.R.color.holo_blue_bright);
			}
		}
		return row;
	}
}
